package com.kun.service;

import com.kun.mapper.OrderMapper;
import com.kun.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Version:v1.0
 * @Author: 鲁坤
 * @Date: 2021-04-08
 * @ClassName: OrderImpl
 * @Description: TODO
 */
@Service("OrderService")
public class OrderImpl implements OrderService{
    @Autowired
    private OrderMapper orderMapper;
    @Override
    @CachePut(value = "orderOfUser",key = "#map")
    public List<Order> getOrderByUserAndStatus(Map<String, Integer> map) {
        return orderMapper.getOrderByUserAndStatus(map);
    }

    @Override
    @CachePut(value = "orderId",key = "#oid")
    public Order getOrderByOid(int oid) {
        return orderMapper.getOrderByOid(oid);
    }

    @Override
    @CachePut(value = "allOrders",key = "#ostatus")
    public List<Order> getOrderByStatus(int ostatus) {
        return orderMapper.getOrderByStatus(ostatus);
    }

    @Override
    public int addOrder(Order order) {
        return orderMapper.addOrder(order);
    }

    @Override
    public int updateOrderStatus(Order order) {
        return orderMapper.updateOrderStatus(order);
    }
}
